package leetcode_core.leetcode_5;

import java.util.Stack;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年01月02日 23:49
 */
public class CQueue {
    private Stack<Integer> f;
    private Stack<Integer> g;
    public CQueue() {
        f = new Stack<>();
        g = new Stack<>();
    }

    public void appendTail(int value) {
        f.push(value);
    }

    public int deleteHead() {
        if(f.empty()){
            return -1;
        }
        if(f.size() == 1){
            return f.pop();
        }
        while (f.size()!=1){
            g.push(f.pop());
        }
        int head = f.pop();
        while (!g.isEmpty()){
            f.push(g.pop());
        }
        return head;
    }
}
